@page
@model IdentityServerTemplate.Pages.Admin.Clients.EditSecretModel

<div class="container-fluid mb-4 px-0">
    <header class="pb-3 mb-4 border-bottom">
        <h1 class=" fw-bold">
            <i class="bi bi-laptop text-brand"></i>
            Edit Client - @Model.Input.ClientId
        </h1>
        <span class="text-muted">
            Edit the configuration for an existing client
        </span>
    </header>
</div>

@if (Model.Updated)
{
    <div class="alert alert-success" role="alert">
        Client Secret updated successfully.
    </div>
}

@if (Model.Cleared)
{
    <div class="alert alert-success" role="alert">
        Client Secrets cleared successfully.
    </div>
}

<div class="client-secrets-page">

    <partial name="_ValidationSummary" />

    <form method="post">

        <div class="form-group mb-3 text-start">

            <a class="btn btn-sm btn-outline-secondary" href="/Admin/Clients/Edit?id=@Model.Input.ClientId"
               data-unsaved="Any unsaved changes will be lost. Are you sure?">
                <i class="bi bi-chevron-double-left"></i>
                Go Back
            </a>

            <button class="btn btn-sm btn-brand"
                    type="submit"
                    name="Button"
                    value="save">
                <i class="bi bi-floppy"></i>
                Save Changes
            </button>

            <button class="btn btn-sm btn-danger"
                    type="submit"
                    name="Button"
                    value="clear"
                    data-confirm="Are you sure you want to clear all Secrets?">
                <i class="bi bi-trash"></i>
                Clear Secrets
            </button>

        </div>

        <div class="row">

            <div class="col-12 col-md-6">

                <div class="card text-bg-light">
                    <h5 class="card-header">
                        <i class="bi bi-incognito"></i>
                        Client Secret
                    </h5>
                    <div class="card-body pt-2">

                        <small class="mb-2 text-body-secondary d-block fst-italic">
                            Set a new client secret for this (<code>@Model.Input.ClientId</code>) client. Saving will clear existing secrets and set this as the current and only secret.
                        </small>

                        <div class="row mb-3">
                            <div class="col-md">
                                <label asp-for="Input.ClientId" class="form-label"></label>
                                <input class="form-control form-control-sm"
                                       asp-for="Input.ClientId"
                                       readonly />
                            </div>

                            <div class="col-md">
                                <label asp-for="Input.Secret" class="form-label"></label>
                                <input class="form-control form-control-sm"
                                       asp-for="Input.Secret" />
                            </div>

                        </div>

                        <div class="row mb-3">

                            <div class="col-md">
                                <label asp-for="Input.Description" class="form-label">Description</label>
                                <input class="form-control form-control-sm"
                                       asp-for="Input.Description"
                                       placeholder="Description" />
                            </div>

                        </div>

                        <div class="alert alert-danger mb-0 mt-4 p-2 ps-3" role="alert">
                            Make sure to keep the secret safe! Once set, it is never available to read in plain-text again.
                        </div>

                    </div>
                </div>

            </div>

        </div>

    </form>

</div>
